import { fetchData } from './utils';
// import { Modal } from 'antd';
const globalConfig = {
  protocal:'http:',
  domain: "www.wiste.cn"
};
const logout = async () => {
  await fetchData({
    url: "/AdminApi/Login/logout",
    method: 'POST'
  });
  location.pathname = '/Admin/Login/index';
};
const logStatusCheck = async (target) => {
  const res = await fetchData({
    url: "/AdminApi/Login/check",
    method: 'POST'
  });
  if (res.error === 1) {
    const url = target ? '/Admin/Login/index?target=' + target : '/Admin/Login/index';
    location.href = url;
  }
};
const getRegionList = (level, dataArr) => {
  if (level == 1) {
    return cityData3;
  } else {
    for (var i = 0; i < cityData3.length; i++) {
      if (cityData3[i].value == dataArr[0]) {
        if (level == 2) {
          return cityData3[i].children;
        } else {
          for (var ind = 0; ind < cityData3[i].children.length; ind++) {
            if (cityData3[i].children[ind].value == dataArr[1]) {
              return cityData3[i].children[ind].children;
            }
          }
        }
      }
    }
  }
  return null;
};
const formatDate = (date) => {
  var Y = date.getFullYear();
  var m = date.getMonth() + 1;
  m = m < 10 ? "0" + m : m;
  var d = date.getDate();
  d = d < 10 ? "0" + d : d;
  return Y + "-" + m + "-" + d;
};

const getBrowserInfo = () => {
  var ua = navigator.userAgent.toLocaleLowerCase();
  var browserType = null,
    browserVersion = null;
  if (ua.match(/msie/) != null || ua.match(/trident/) != null) {
    browserType = "IE";
    browserVersion =
      ua.match(/msie ([\d.]+)/) != null
        ? ua.match(/msie ([\d.]+)/)[1]
        : ua.match(/rv:([\d.]+)/)[1];
  } else if (ua.match(/firefox/) != null) {
    browserType = "火狐";
  } else if (ua.match(/ubrowser/) != null) {
    browserType = "UC";
  } else if (ua.match(/opera/) != null) {
    browserType = "欧朋";
  } else if (ua.match(/bidubrowser/) != null) {
    browserType = "百度";
  } else if (ua.match(/metasr/) != null) {
    browserType = "搜狗";
  } else if (
    ua.match(/tencenttraveler/) != null ||
    ua.match(/qqbrowse/) != null
  ) {
    browserType = "QQ";
  } else if (ua.match(/maxthon/) != null) {
    browserType = "遨游";
  } else if (ua.match(/chrome/) != null) {
    var is360 = false;
    var mimeTypes = navigator.mimeTypes;
    for (var mt in mimeTypes) {
      if (mimeTypes[mt]["type"] == "application/vnd.chromium.remoting-viewer") {
        is360 = true;
      }
    }
    if (is360) {
      browserType = "360";
    } else {
      browserType = "Chrome";
    }
  } else if (ua.match(/safari/) != null) {
    browserType = "Safari";
  }
  return browserType + "-" + browserVersion;
};
export { logout, logStatusCheck ,globalConfig};